<template>
    <div :class="['indexHeader partBg',{'nav_bars':homeindex}]">
        <div class="flex">
            <p @click="themeChange('dark')">dark</p>
            <p @click="themeChange('white')">white</p>
            <p><router-link :to="{ path: '/'}">首页</router-link></p>
            <p><router-link :to="{ path: '/c2c'}">C2C交易</router-link></p>
            <p><router-link :to="{ path: '/legalTrade'}">法币交易</router-link></p>
            <p><router-link :to="{ path: '/homeContent'}">币币交易</router-link></p>
            <p><router-link :to="{ path: '/MyLegalShops'}">我的商铺</router-link></p>
            <p><router-link :to="{ path: '/login'}">登录</router-link></p>
            <p><router-link :to="{ path: '/register'}">注册</router-link></p>
            <div class="flex">
                <span class="plr10 pointer" @click="setLang('zh')">中</span>
                <span class="plr10 pointer" @click="setLang('en')">En</span>
            </div>
            <p>{{$t('test')}}</p>
        </div>
    </div>
</template>
<script>
export default {
    data(){
        return{
            homeindex:true,
        }
    },
    watch: {
        $route(to, from) {
            if(this.$route.path!=='/'){
                this.homeindex=false;
            }else{
                this.homeindex=true;
            }
        }
    },
    created(){
        if(this.$route.path!=='/'){
            this.homeindex=false;
        }else{
            this.homeindex=true;
        }
    },
    methods:{
        themeChange(type){
            this.$utils.theme(type);
        },
        setLang(lang) {
            var l = window.localStorage.getItem("locale") || "zh";
            if (l == lang) {
                return;
            } else {
                window.localStorage.setItem('locale',lang);
                this.$i18n.locale = lang;
                window.location.reload();
            }
        },
    }
}
</script>
<style lang="scss" scoped>
.indexHeader{
    width: 100%;
    height: 48px;
    line-height: 48px;
    p{
        padding: 0 20px;
    }
    .router-link-exact-active {
        color: #7a98f7;
    }
}
.nav_bars{
  background-color: rgba(0,0,0,.15);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 99;
}
</style>

